﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using BizControl.Library.BusinessObjects.Activities;
using BizControl.Library.BusinessObjects.People;
using BizControl.Library.BusinessObjects.Models;
using BizControl.Library.BusinessObjects.Comments;

namespace BizControl.Library.Tests
{
  [TestClass]
  public class ActivityBOFixture
  {
    [TestMethod]
    public void CanCreateActivity()
    {
      var personInfo = PersonList.GetPersonList().First();
      var person = PersonBO.GetPerson(personInfo.Id);
      var model = person.Models.AddModel(ModelBO.NewModel()).Model;
      model.Name = "Model #3";
      model = model.Save();
      var activity = ActivityBO.NewActivity(person, model); // model and person should be saved
      activity.Description = "My first activity";
      activity.LastChangedBy = person;
      activity = activity.Save();
    }

    [TestMethod]
    public void CanChangeActivity()
    {
      var personInfo = PersonList.GetPersonList().First();
      var person = PersonBO.GetPerson(personInfo.Id);
      var activityInfo = ActivityList.GetActivityList(person, person.Models[0].Model).First();
      var activity = ActivityBO.GetActivity(activityInfo.Id);
      string description = activity.Description + "!";
      activity.Description = description;
      activity = activity.Save();
      Assert.AreEqual(description, ActivityBO.GetActivity(activity.ActivityId).Description);
    }

    [TestMethod]
    public void CheckAttributes()
    {
      var activity = ActivityBO.NewActivity(PersonBO.NewPerson(), ModelBO.NewModel());
      activity.Comments.AddComment();
      activity.Save();
    }

    [TestMethod]
    public void CheckValidation()
    {
      var activity = ActivityBO.NewActivity(PersonBO.NewPerson(), ModelBO.NewModel());
      activity.Priority = 10;
      activity.Save();
    }

  }
}
